package com.yxw.yx_hotel.controller;

import com.yxw.yx_hotel.dto.AddRoomFeeDto;
import com.yxw.yx_hotel.dto.QueryRoomFeeDto;
import com.yxw.yx_hotel.dto.UpdateRoomFeeDto;
import com.yxw.yx_hotel.service.RoomFeeService;
import com.yxw.yx_hotel.vo.RoomFeeVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 *  宿舍费用管理
 * @author liuxin
 * @date 2024.01.18
 */
@RestController
@Api(value = "宿舍费用管理", tags = "宿舍费用管理")
@Slf4j
@RequestMapping("/api/roomFee")
public class RoomFeeController {

    @Autowired
    private RoomFeeService roomFeeService;

    @ApiOperation(value = "新增宿舍费用信息")
    @PostMapping("/addRoomFee")
    public BaseResult addRoomFee(@Validated @RequestBody AddRoomFeeDto dto)  {
        roomFeeService.addRoomFee(dto);
        return BaseResult.doSuccess(null,"新增成功");
    }

    @ApiOperation(value = "查询宿舍费用列表")
    @PostMapping("/pageRoomFeeList")
    public BaseResult<PageVO<RoomFeeVo>> pageRoomFeeList(@Validated @RequestBody QueryRoomFeeDto dto)  {
        PageVO<RoomFeeVo> pageVo=roomFeeService.pageRoomFeeList(dto);
        return BaseResult.doSuccess(pageVo,"查询成功");
    }

    @ApiOperation(value = "查询费用详情")
    @GetMapping("/getRoomFeeById")
    public BaseResult<RoomFeeVo> getRoomFeeById(@RequestParam Long feeId)  {
        RoomFeeVo vo=roomFeeService.getRoomFeeById(feeId);
        return BaseResult.doSuccess(vo,"查询成功");
    }

    @ApiOperation(value = "更新宿舍费用信息")
    @PostMapping("/updateRoomFee")
    public BaseResult updateRoomFee(@Validated @RequestBody UpdateRoomFeeDto dto)  {
        roomFeeService.updateRoomFee(dto);
        return BaseResult.doSuccess(null,"更新成功");
    }
}
